package telbook;

import java.util.HashMap;
import java.util.Map;

public class FormBean {
	private String username;
	private String password;
	private String password2;
	private Map<String,String> errors=new HashMap<String,String>();
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPassword2() {
		return password2;
	}
	public void setPassword2(String password2) {
		this.password2 = password2;
	}
	public boolean validate() {
		boolean flag=true;
		if(username.length()!=11) {
			errors.put("username", "请输入正确的手机号码");
			flag=false;
		}
		if(password.length()>20||password.length()<6) {
			errors.put("password", "请输入6-20位字符");
			flag=false;
		}
		if(!password.equals(password2)) {
			errors.put("password2", "两次密码输入不一致");
			flag=false;
		}
		return flag;
	}
	public void setErrorMsg(String err,String errMsg) {
		if((err!=null)&&(errMsg!=null)) {
			errors.put(err, errMsg);
		}
	}
	public Map<String,String> getErrors(){
		return errors;
	}
}
